<?php 
$path = "/tuiliu/data";

$dir = getDirContent("$path");

if ($dir) {
    foreach ($dir as $k => $v) {
        $content = shell_exec("tail -c 100 $path/$v");
        $data[$v] = $content;
    }
}

echo json_encode($data);

function getDirContent($path){
    if(!is_dir($path)){
      return false;
    }
    //readdir方法
    /* $dir = opendir($path);
    $arr = array();
    while($content = readdir($dir)){
      if($content != '.' && $content != '..'){
        $arr[] = $content;
      }
    }
    closedir($dir); */
   
    //scandir方法
    $arr = array();
    $data = scandir($path);
    foreach ($data as $value){
      if($value != '.' && $value != '..'){
        $arr[] = $value;
      }
    }
    return $arr;
  }